<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form-model ref="formRef">
        <div class="search-title">查询条件</div>
        <a-row>
          <a-col :span="4">
            <div style="margin-right: 12px">
              <a-form-model-item prop="id"
                ><a-input v-model="queryParam.id" placeholder="请输入RFID标签流水号" allowClear />
              </a-form-model-item>
            </div>
          </a-col>
          <a-col :span="4">
            <div style="margin-right: 12px">
              <a-form-model-item prop="rfidBar"
                ><a-input v-model="queryParam.rfidBar" placeholder="请输入RFID码" allowClear />
              </a-form-model-item>
            </div>
          </a-col>
         

         

          <a-col :span="4">
            <div style="margin-top: 4px">
              <a-button icon="search" style="margin-right: 20px" @click="searchQuery()" type="primary"> 查询 </a-button>
              <a-button icon="reload" style="margin-right: 20px" @click="searchReset()"> 重置 </a-button>
            </div>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8">
            <div style="margin-top: 4px">
              <a-button icon="plus" style="margin-right: 20px" @click="handleAdd" type="primary">
                新增
              </a-button>
            </div>
          </a-col>
        </a-row>
      </a-form-model>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- 高级查询区域 -->
      <!-- <j-super-query
            :fieldList="superFieldList"
            ref="superQueryModal"
            @handleSuperQuery="handleSuperQuery"
          ></j-super-query> -->
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
       <!-- 槽 渲染 指定 cloumn的值 -->
       <span slot="statueSlot" slot-scope="text, record">
          <a-tag :color="onColor(text)">
            {{ OnStatue(text) }}
          </a-tag>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>

    <product-modal ref="modalForm" @ok="modalFormOk"></product-modal>
  </a-card>
</template>

<script>
import { mapState, mapGetters } from 'vuex'
import { stateObjToArray } from '@/utils/common.js'

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import productModal from './modules/productModal'

export default {
  name: 'productList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    productModal,
  },
  data() {
    return {
      description: '产品信息',
      // 表头
      columns: [
        {
          title: '产品名称',
          align: 'center',
          dataIndex: 'productName',  
        },
        {
          title: '产品品码',
          align: 'center',
          dataIndex: 'productZxxsdycpbs',
        },
        {
          title: '规格/型号',
          align: 'center',
          dataIndex: 'productSpec',
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'productUnit',
        },
        {
          title: '产品属性',
          align: 'center',
          dataIndex: 'productAttributes',
        },
        {
          title: '生产厂商',
          align: 'center',
          dataIndex: 'productCpbsbmtxmc',
        },

        {
          title: '库存上限',
          align: 'center',
          dataIndex: 'inventoryUpperLimit',
        },
        {
          title: '库存下线',
          align: 'center',
          dataIndex: 'inventoryLowerLimit',
        },
        {
          title: '产品单重(g)',
          align: 'center',
          dataIndex: 'singleWeight',
        },
       
        {
          title: '是否启用',
          align: 'center',
          dataIndex: 'isEnabled',
          scopedSlots: { customRender: 'statueSlot' },
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          align: 'center',
        },

        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],

      url: {
        list: '/bms/bmsProductInfo/likeList',
        delete: '/bms/bmsProductInfo/delete',
        deleteBatch: '/wms/wmsSaleOrder/deleteBatch',
        exportXlsUrl: 'wms/wmsZdyUdiMainTaskDetail/exportXls',
        importExcelUrl: 'wms/wmsSaleOrder/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    ...mapGetters(['userInfo']),
    ...mapState({
      saleOrderTypes: (s) => {
        return stateObjToArray(s.order.saleOrderTypes)
      },
      inOrderStates: (s) => s.order.inOrderStates,
      saleOrderStates: (s) => {
        return stateObjToArray(s.order.saleOrderStates)
      },
      warehouseOptions: (s) => {
        return stateObjToArray(s.dictionary.enableWarehouse)
      },
      enableWarehouse: (s) => s.dictionary.enableWarehouse,
    }),
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}${this.url.importExcelUrl}`
    },
  },
  methods: {
    // dateChange(e) {
    //   console.log(e);
    //   this.queryParam.createTime = moment(e._d).format('YYYY-MM-DD')
    // },

    //状态
    OnStatue(text) {
      let title = ''
      if (text == 0) title = '停用'
      if (text == 1) title = '启用'
      return title
    },
    // 状态颜色
    onColor(text) {
      let color = ''
      if (text == 0) color = 'red'
      if (text == 1) color = 'green'
      return color
    },
   
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'orderNo', text: '订单号' })
      fieldList.push({ type: 'string', value: 'orderType', text: '订单类型' })
      fieldList.push({ type: 'string', value: 'state', text: '状态' })
      fieldList.push({ type: 'int', value: 'sums', text: '数量' })
      fieldList.push({ type: 'int', value: 'createBy', text: '创建人' })
      fieldList.push({ type: 'string', value: 'createTime', text: '公司' })
      fieldList.push({ type: 'string', value: 'warehourse', text: '所属仓库' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.search-title {
  font-size: 16px;
  font-weight: 650;
  margin-bottom: 10px;
}
.ant-form-item {
  margin-bottom: 8px;
}
</style>
